<template>
    <div class="photoInf_box">
        <div class="title">
            <h3>
                {{infoList.title}}
            </h3>
            <p class="intrduce">
                <span>发表时间：{{infoList.add_time | timeF}}</span>
                <span>点击：{{infoList.click}}次</span>
            </p>
        </div>
        <hr>
        <div class="content">
            <vue-preview :slides="imgList" @close="handleClose"></vue-preview>
            <p class="text" v-html="infoList.content"></p>
        </div>
        <comment-box :infoId='this.id'></comment-box>
    </div>
</template>
<script>
// 引入评论子组件
import comment from '../comment/connent.vue'
export default {
    data(){
        return {
            id:this.$route.params.id,
            imgList : [],
            infoList:{}
        }
    },
    created(){
       this.getImgList(this.id)
       this.getPhotoInfoList(this.id)
       this.handleClose()
    },
    methods:{
        // 获取详情页面缩略图
        getImgList(id){
            this.$http.get('api/getthumimages/'+id).then(res=>{
                if (res.body.status == 0){
                    res.body.message.forEach(item => {
                        item.msrc = item.src
                        item.w = 600
                        item.h = 400
                    });
                    this.imgList = res.body.message
                }
            })
        },
        // 获取图片详情页面中的详细描述信息
        getPhotoInfoList(id){
            this.$http.get('api/getimageInfo/'+id).then(res=>{
                if (res.body.status == 0){
                    this.infoList = res.body.message[0]
                }
            })
        },
        handleClose () {}
    },
    components:{
        'comment-box':comment
    }
}
</script>
<style lang="scss">
.photoInf_box {
    padding: 5px;
    .title{
        h3{
            color: #26a2ff;
            font-size: 15px;
            text-align: center;
            margin: 15px 0;
        }
        .intrduce {
            display: flex;
            justify-content: space-between
        }
    }
    .my-gallery {
        display: flex;
        flex-wrap: wrap;
        figure {
            margin: 0;
            padding: 0;
            width: 33.33%;
            padding: 10px;
            img {
                width: 100%;
                box-shadow: 0 0 8px #999;
                vertical-align: middle;
            }
        }
    }
    .text {
        font-size: 13px;
        line-height: 30px;
        color: #000;
    }
}
</style>
